package com.fr.report.script.function;

import com.fr.report.script.Function;
import com.fr.report.script.Function.Type;
import com.fr.report.script.NormalFunction;
import com.fr.report.script.Primitive;
import com.fr.report.script.core.FunctionHelper;

public class ASIN extends NormalFunction
{
  public Object run(Object[] paramArrayOfObject)
  {
    if (paramArrayOfObject.length < 1)
      return Primitive.ERROR_NAME;
    double d = 0.0D;
    for (int i = 0; i < paramArrayOfObject.length; ++i)
      if (paramArrayOfObject[i] instanceof Number)
      {
        d = Math.asin(((Number)paramArrayOfObject[i]).doubleValue());
        break;
      }
    return FunctionHelper.parsePrimitiveDouble(d);
  }

  public Function.Type getType()
  {
    return Function.MATH;
  }

  public String getCN()
  {
    return "ASIN(number): 返回指定数值的反正弦值。反正弦值为一个角度，返回角度以弧度形式表示。\nNumber:需要返回角度的正弦值。\n备注:\n    指定数值必须在-1到1之间（含1与-1）。\n    返回角度在-pi/2到pi/2之间（含-pi/2与pi/2）。\n    用角度形式返回数值时，返回数值乘以180/PI()。\n示例:\nASIN(0.5)等于0.523598776（pi/6弧度）。\nASIN(1)等于1.570796327（pi/2弧度）。\nASIN(0.5)*180/PI()等于30（度）。";
  }

  public String getEN()
  {
    return "ASIN(number): Returns the arcsine, or inverse sine, of a number. The arcsine is the angle whose sine is number. The returned angle is given in radians.\nNumber is the sine of the angle.\n\nRemarks:\n    Number is in the range -1 to 1.\n    The returned angle is in the range -pi/2 to pi/2.\n    To express the arcsine in degrees, multiply the result by 180/PI( ) or use the DEGREES function.\n\nExample:\n   ASIN(0.5)=0.523598776 (pi/6 in radians)\n   ASIN(1)=1.570796327 (pi/2 in radians)\n   ASIN(0.5)*180/PI()=30 (in degrees)";
  }
}